package com.naszetatry.profiles;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.naszetatry.controller.UsersSearchController;
import com.naszetatry.logic.UserLogic;
/**
 * Serwlet odpowiedzialny za wyszukiwarke uzytkownikow.
 * @author Maciej Koch
 *
 */
public class UsersSearch extends HttpServlet{

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		if("1".equals(request.getParameter("do"))) {
			getServletContext().getRequestDispatcher("/jsp/usersSearch.jsp").forward(request, response);	
			return;
		}
		String login = request.getParameter("login");
		List<String> users = UserLogic.loadUserLogins(login);

		UsersSearchController.setSearchedUsers(request, users);
		getServletContext().getRequestDispatcher("/jsp/usersSearch.jsp").forward(request, response);
	}
}
